﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MvcApplication6.Models;
using MvcApplication6.DAL;

namespace MvcApplication6.BIZ
{
    public class ProductBIZ
    {
        ProductDAL DAL = new ProductDAL();

        //-----------------ProductSearchById--------------------------
        public ProductModel ProductSearchById(int id)
        {
            try
            {
                ProductModel lst = DAL.ProductSearchById(id);

                return lst;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-----------------ProductSearchById_l1--------------------------
        public List<ProductModel> ProductSearchById_l1(int id_l1)
        {
            try
            {
                List<ProductModel> lst = new List<ProductModel>();
                lst = DAL.ProductSearchById_l1(id_l1);

                return lst;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-----------------ProductSearchById_l2--------------------------
        public List<ProductModel> ProductSearchById_l2(int id_l2)
        {
            try
            {
                List<ProductModel> lst = new List<ProductModel>();
                lst = DAL.ProductSearchById_l2(id_l2);

                return lst;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-----------------ProductSearchById_l3--------------------------
        public List<ProductModel> ProductSearchById_l3(int id_l3)
        {
            try
            {
                List<ProductModel> lst = new List<ProductModel>();
                lst = DAL.ProductSearchById_l3(id_l3);

                return lst;
            }
            catch (Exception)
            {
                throw;
            }
        }
		
		 //-----------------ProductSearchById_l3--------------------------
        public List<ProductModel> ProductDetailById_l(int id, int LevelMenu)
        {
            try
            {
                List<ProductModel> lst = new List<ProductModel>();
                lst = DAL.ProductDetailById_l(id, LevelMenu);

                return lst;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-----------------ProductInsert--------------------------
        public int ProductInsert(int id_l1, int id_l2, int id_l3, string image,
                                int position1, int position2, int position3, int position4, int position5, int position6, int newpro_flag, int prosales_flag,
                                int prosale_flag, string name, string title, string warranty, string make_in, float price,
                                int sale, string introduce_pro, string inf_pro, string int_pro)
        {
            try
            {
                int i = DAL.ProductInsert(id_l1, id_l2, id_l3, image,
                                position1, position2, position3, position4, position5, position6, newpro_flag, prosales_flag,
                                prosale_flag, name, title, warranty, make_in, price,
                                sale, introduce_pro, inf_pro, int_pro);

                return i;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-----------------ProductUpdate with id--------------------------
        public int ProductUpdate(int id, int id_l1, int id_l2, int id_l3, string image,
                                int position1, int position2, int position3, int position4, int position5, int position6, int newpro_flag, int prosales_flag,
                                int prosale_flag, string name, string title, string warranty, string make_in, float price,
                                int sale, string introduce_pro, string inf_pro, string int_pro)
        {
            try
            {
                int i = DAL.ProductUpdate(id, id_l1, id_l2, id_l3, image,
                                position1, position2, position3, position4, position5, position6, newpro_flag, prosales_flag,
                                prosale_flag, name, title, warranty, make_in, price,
                                sale, introduce_pro, inf_pro, int_pro);

                return i;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-----------------ProductDelete with id--------------------------
        public int ProductDelete(int id)
        {
            try
            {
                int i = DAL.ProductDelete(id);

                return i;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-------------------------Update Sale-------------------------------
        public int ProductUpdateSaleByID_L1(int id_l1, int sale)
        {
            try
            {
                int i = DAL.ProductUpdateSaleByID_L1(id_l1, sale);

                return i;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-------------------------Update Sale-------------------------------
        public int ProductUpdateSaleByID_L2(int id_l2, int sale)
        {
            try
            {
                int i = DAL.ProductUpdateSaleByID_L2(id_l2, sale);

                return i;
            }
            catch (Exception)
            {
                throw;
            }
        }

        //-------------------------Update Sale-------------------------------
        public int ProductUpdateSaleByID_L3(int id_l3, int sale)
        {
            try
            {
                int i = DAL.ProductUpdateSaleByID_L3(id_l3, sale);

                return i;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}